<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>品牌列表 - easyui</title>
		<%@ include file="/common/include/title.jsp"%>
		
		<script type="text/javascript">
			$(function(){
				initPagation();
			})
			
			/* 初始化分页插件 */
			function initPagation()
			{
				//设置分页控件 
	            var p = $('#dataGrid').datagrid('getPager');
	            $(p).pagination({
	                pageSize: 10, //每页显示的记录条数，默认为10 
	                pageList: [10, 20, 30], //可以设置每页记录条数的列表 
	                onSelectPage: function (pageNumber, pageSize) {
	                    /* Query();//分页查询 */
	                    /* alert(pageNumber + "-----" + pageSize); */
	                    initQuery(pageNumber,pageSize);
	                }
	            });
			}
			
			/* 分页查询数据 */
			function initQuery(page,pageSize)
			{
	            var opts = $('#dataGrid').datagrid('options');
	            /* var page = opts.pageNumber;//获取页码
	            var pageSize = opts.pageSize;//获取每页多少记录 */
	            var status = $("#status").val();
	            var keyword = $("#keyword").val();
	            
	            /* 获取查询条件 */
	            var status = $("#status").val();
	            var keyword = $("#keyword").val();
	            
	            /* 拼装url */
	            var handler = "${rootPath }/back/goods/brandListJSON.htm?page=" + page+ "&rows=" + pageSize 
	            		+ "&status=" + status + "&keyword=" + keyword;
	            /* alert("---------------" + handler) */

	           	opts.url = handler; //设置表格数据的来源URL
	           	opts.pageNumber = page; //重新加载表格
	            $('#dataGrid').datagrid('reload'); //重新加载表格
	            return false ;
			}
			
			/* 添加数据 */
			function addData()
			{
				addTabs(window.parent,"管理员添加","insert.html");
				return false ; 
			}
			
			/* 删除数据 */
			function removeData()
			{
				var row = $("#dataGrid").datagrid("getSelected");
				if(row)
				{
					/* 测试数据 */
					var sb = "" ; 
					for(var wangsh in row )
					{
						sb += wangsh + "-->" + row[wangsh] + "\r\n"; 
					}
					alert(sb + '---' + row.title)
					$.messager.confirm("确认","确认要删除吗?",function(data)
					{
						if(data)
						{
							/* 点击确认操作 */
							$.messager.alert("警告框","已经删除")
						}
						return false ; 
					});
				}
				return false ; 
			}
		</script>
	</head>
	<body>
		<!-- 测试数据 -->
		<table id="dataGrid" class="easyui-datagrid" title="测试数据"
			data-options="
				url:'${rootPath }/back/goods/brandListJSON.htm',
				method:'post',
				border:false,
				singleSelect:true,
				fit:true,
				fitColumn:true,
				collapsible:true,
				rownumbers:true,
				pagination:true,
				toolbar:'#gridToolsbar'">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'count'" width="">序号</th>
					<th data-options="field:'id'" width="80">id</th>
					<th data-options="field:'adminsName'" width="100">管理员</th>
					<th data-options="field:'name'">名称</th>
					<th data-options="field:'website'" width="100">网址</th>
					<th data-options="field:'logoPath'" width="100">logoPath</th>
					<th data-options="field:'statusStr'">状态</th>
					<th data-options="field:'createTime'">创建时间</th>
					<th data-options="field:'updateTime'">更新时间</th>
					<th data-options="field:'pubTime'">发布时间</th>
					
				</tr>
			</thead>
		</table>
		<!-- 表格的工具栏 -->
		<div id="gridToolsbar">
			<div>
				<input id="keyword" name="keyword" class="easyui-textbox" placeholder="请输入关键字">
				<select id="status" name="status">
					<option>请选择</option>
					<option value="1">启用</option>
					<option value="0">禁用</option>
				</select>
				<input id="st" class="easyui-datetimebox" name="st" placeholder="请输入时间" data-options="">
				<input id="ed" class="easyui-datetimebox" name="ed" placeholder="请输入时间" data-options="">
				<a href="" onclick="return initQuery('1','10')" class="easyui-linkbutton" data-options="iconCls:'icon-search'" plain="true">搜索</a>
			</div>
			<div>
				<a href="#" class="easyui-linkbutton" title="添加"
					data-options="iconCls:'icon-add'" plain="true"
					onclick="return addData()">添加</a> <a href="#"
					class="easyui-linkbutton" title="更新"
					data-options="iconCls:'icon-edit'" plain="true"
					onclick="return addData()">更新</a> <a href="#"
					class="easyui-linkbutton" title="删除"
					data-options="iconCls:'icon-remove'" plain="true"
					onclick="return removeData()">删除</a>
			</div>
		</div>
	</body>
</html>